<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<?php
date_default_timezone_set('Australia/Melbourne');
$fileName="recorder.csv";
$arrayShipping = array();
$arrayPacking = array();
$arrayProduct = array();
//using the File exchange file today

 
//export the sales result


//export the Postage and Packing 
$fl = fopen($fileName,"r");
while(($lineData = fgetcsv($fl,0))!= FALSE){
	//$arrayShipping[]= $lineData[2];
	$arrProductTemp = explode(",",$lineData[1]);
	$arrayProduct= array_merge($arrayProduct,$arrProductTemp);
	array_push($arrayShipping,$lineData[2]);
	//$arrayPacking[] = $lineData[4];
	array_push($arrayPacking,$lineData[4]);
//echo $lineData[2];
	echo ".";
	}

$arrayShippingResult = array_count_values($arrayShipping);

$arrayResultData = array();
$arrayResultData = array_fill(0,19,"0");

foreach($arrayShippingResult as $key => $value){
	switch($key){
		case("**RRAC60**"):$arrayResultData[1] = $value;break;
		case("**RRAC120**"):$arrayResultData[2] = $value;break;
		case("**RRAC180**"):$arrayResultData[3] = $value;break;
		case("**RST60**"):$arrayResultData[4] = $value;break;
		case("**RST12**"):$arrayResultData[5] = $value;break;
		case("**RST18**"):$arrayResultData[6] = $value;break;
		case("**REGLB**"):$arrayResultData[7] = $value;break;
		case("**REP500**"):$arrayResultData[8] = $value;break;
		case("**REP3KG**"):$arrayResultData[9] = $value;break;
		case("**REP5KG**"):$arrayResultData[10] = $value;break;
		case("**EXS500**"):$arrayResultData[11] = $value;break;
		case("**EXS3KG**"):$arrayResultData[12] = $value;break;
		case("**EXS5kG**"):$arrayResultData[13] = $value;break;
		case("**EXSE**"):$arrayResultData[14] = $value;break;
		case("**FAYA2**"):$arrayResultData[15] = $value;break;
		case("**FAYA3**"):$arrayResultData[16] = $value;break;
		case("**FAYA5**"):$arrayResultData[17] = $value;break;
		case("**FAYLO**"):$arrayResultData[18] = $value;break;
		}
	
	}

$arrayResultData[0] = date("Y-m-d");
$shipFileName="shippingmethod.csv";
$fl = fopen($shipFileName,"a");
fputcsv($fl,$arrayResultData);
fclose($fl);

//print_r($arrayResultData);
$arrayPackingResult = array_count_values($arrayPacking);

$arrayResultPackingData = array();
$arrayResultPackingData = array_fill(0,7,"0");

foreach($arrayPackingResult as $key => $value){
	switch($key){
		case("**FREEPK**"):$arrayResultPackingData[1] = $value;break;
		case("**PEB11**"):$arrayResultPackingData[2] = $value;break;
		case("**PEC5**"):$arrayResultPackingData[3] = $value;break;
		case("**PEDL**"):$arrayResultPackingData[4] = $value;break;
		case("**PEC4**"):$arrayResultPackingData[5] = $value;break;
		case("9312650900014"):$arrayResultPackingData[6] = $value;break;
		}
	
	}
$arrayResultPackingData[0] = date("Y-m-d");
$packFileName="packingmethod.csv";
$fl = fopen($packFileName,"a");
fputcsv($fl,$arrayResultPackingData);
fclose($fl);	
//print_r(array_count_values($arrayPacking));	

//print_r(array_count_values($arrayProduct));	

$productFileName = "product.csv";
$fl = fopen($productFileName,"a");
foreach(array_count_values($arrayProduct) as $key =>$value){
		
		$arrTemp = array();
		
		$arrTemp[0] = $key;
		$arrTemp[1]	= $value;
		
		fputcsv($fl,$arrTemp);	
	}
fclose($fl);



//export the csv for uploading to eBay
echo "DONE"; 
?>
</body>
</html>